#include<string.h>

int countAsterisks(char *s)
{
    int count = 0, left = 0, right = 0;
    while (left + right < 2 * strlen(s))
    {
        for (right = left; right < strlen(s); right++)
        {
            if (s[right] == '|' && s[left] == '|' && right != left)
            {
                break;
            }
            else if (s[left] != '|')
            {
                if (s[left] == '*')
                {
                    count++;
                }
                left++;
                right = left - 1;
            }
        }
        for (left = right + 1; left < strlen(s); left++)
        {
            if (s[left] == '*')
            {
                count++;
            }
            else if (s[left] == '|')
            {
                right = left + 1;
                break;
            }
        }
    }
    return count;
}